home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows2 / hp22d3.zip / REFGUIDE / CURROBJ.TXT < prev    next >
Text File  |  1991-05-16  |  5KB  |  162 lines

  1.  
  2.  
  3.  
  4.  
  5.     _______________________________________________________________________
  6.                                       Chapter 5: The Current Object   47
  7.     ________________________________________________________________________
  8.  
  9.  
  10.     CHAPTER FIVE: THE CURRENT OBJECT
  11.  
  12.     This chapter describes HyperPAD's facilities for referencing the current
  13.     object, the object that first received the message, and the object whose
  14.     script is currently executing. Reference each of these directly with the
  15.     object names: currentObject, target, and me.
  16.  
  17.  
  18.     THE CURRENT OBJECT
  19.  
  20.     The current object is either a highlighted button, or a field that is
  21.     highlighted or being edited. The current object will only change when
  22.     the focus changes, either by pressing TAB or clicking on a different
  23.     object.
  24.  
  25.     You can refer to the current object in a script using the reserved
  26.     object name currentObject, like the following example:
  27.  
  28.     set the color of the currentObject to red;
  29.  
  30.     put "hello there" into the currentObject;
  31.  
  32.     Also, you can determine the full name of the current object using the
  33.     currentObject() function:
  34.  
  35.     put the currentObject;
  36.  
  37.     if word 1 of currentObject() is "bkgnd" then
  38.       answer "The current object is on the background";
  39.  
  40.     This function returns the name of the current object in the form:
  41.  
  42.     page button id 2
  43.  
  44.     page field id 5
  45.  
  46.     bkgnd button id 45
  47.  
  48.     bkgnd field id 3
  49.  
  50.  
  51.  
  52.     _______________________________________________________________________
  53.                                       Chapter 5: The Current Object   48
  54.     ________________________________________________________________________
  55.  
  56.  
  57.     THE TARGET
  58.  
  59.     The target references the object that initially received the message.
  60.     This is the object at the start of the hierarchy for this message,
  61.     either a button, a field, or a page. Use the target as an object in
  62.     scripts, like in the following examples:
  63.  
  64.     put "Wowee" into the target;
  65.  
  66.     if the hilite of the target then
  67.       set the focus to button "Help";
  68.  
  69.     set the check of the target to false;
  70.  
  71.     set the color of the target to blue;
  72.  
  73.     You can also refer to the name of the target using the target()
  74.     function. Examples of returned text are:
  75.  
  76.     page field id 2
  77.  
  78.     bkgnd button id 1
  79.  
  80.     page id 3
  81.  
  82.     These statements use the target () function:
  83.  
  84.     put the target into the message box;
  85.  
  86.     if word 2 of target() is "button" then
  87.       set the check of the target to 31;
  88.  
  89.     A good example of the use of target is shown with the following two page
  90.     handlers that modify a button's border when the mouse enters the
  91.     button's rectangle.
  92.  
  93.     handler mouseEnter;
  94.     begin
  95.       if word 2 of target() is "button" then
  96.         set the edgeType of the target to 2;
  97.     end;
  98.  
  99.     handler mouseLeave;
  100.     begin
  101.       if word 2 of target() is "button" then
  102.         set the edgeType of the target to 1;
  103.     end;
  104.  
  105.  
  106.  
  107.     _______________________________________________________________________
  108.                                       Chapter 5: The Current Object   49
  109.     ________________________________________________________________________
  110.  
  111.  
  112.     THE CURRENT EXECUTING OBJECT
  113.  
  114.     The owner of the currently executing script can be referred to by the
  115.     object named me. For example:
  116.  
  117.     put the name of me into the message box;
  118.  
  119.     get the rectangle of me;
  120.  
  121.     if the loc of me is "10,10" then
  122.       set the loc of me to 20,20;
  123.  
  124.     The following statements belong in a field's script:
  125.  
  126.     put "Hello World" into me;
  127.  
  128.     put page field 2 before me;
  129.  
  130.     Note: Care must be taken when using me, make sure that the use of me is
  131.     consistent with the type of object that owns the script. For example,
  132.     you would not want to put the following statement into a button's
  133.     script:
  134.  
  135.     put "hello world" into me;
  136.  
  137.     This statement will only work within a field's script.
  138.  
  139.  
  140.     REFERENCING CURRENT OBJECTS WITH "THIS"
  141.  
  142.     You can reference the current page, background, or pad with the word
  143.     this. For example, all of the following refer to current objects in the
  144.     hierarchy.
  145.  
  146.     this page
  147.  
  148.     this background
  149.  
  150.     this pad
  151.  
  152.     You can use these object names in your PADtalk statements:
  153.  
  154.     go to this page;
  155.  
  156.     put the name of this background into msg;
  157.  
  158.     if the name of this pad is "home" then quit;
  159.  
  160.     set the cantDelete of this page to true;
  161.  
  162.     You cannot use the word this to refer to buttons or fields.